from django.db import models

# Create your models here.

from django.contrib.auth.models import AbstractUser
from core.models import CoreModel


class Users(AbstractUser, CoreModel):
    username = models.CharField(
        max_length=150,
        unique=True,
        db_index=True,
        verbose_name="用户账号",
        help_text="用户账号",
    )
    email = models.EmailField(
        max_length=255, verbose_name="用户邮箱", null=True, blank=True, help_text="用户邮箱"
    )
    avatar  = models.ImageField(upload_to="avatars/", verbose_name="用户头像", default="avatars/default.jpg",null=True, blank=True, help_text="用户头像")
    nickname = models.CharField(max_length=40, null=True, blank=True,verbose_name="用户昵称", help_text="用户昵称")
    status = models.BooleanField(default=True, verbose_name="状态", help_text="状态")
    GENDER_CHOICES = (
        (0, "未知"),
        (1, "男"),
        (2, "女"),
    )
    gender = models.IntegerField(
        choices=GENDER_CHOICES,
        default=0,
        verbose_name="性别",
        null=True,
        blank=True,
        help_text="性别",
    )

    class Meta:
        db_table = "system_users"
        verbose_name = "用户管理"
        verbose_name_plural = verbose_name
        ordering = ("id",)

    def __str__(self) -> str:
        return self.username
